﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace WXJHToolBox
{
    public class Common
    {
        public enum DtyTimeSpece
        {
            [Description("无")]
            No = 0,
            [Description("秒")]
            Second = 1,
            [Description("分钟")]
            Minute = 60,
            [Description("小时")]
            Hour = 3600,
            [Description("日")]
            Day = 86400,
            [Description("月")]
            Month = 2592000,
            [Description("年")]
            Year = 31104000
        }

        public enum DtySimple
        {
            [Description("第一个值")]
            First = 1,
            [Description("最后一个值")]
            Last,
            [Description("最小值")]
            Min,
            [Description("最大值")]
            Max,
            [Description("平均值")]
            Avg,
            [Description("总和")]
            Sum,
            [Description("记录数")]
            Count
        }

        public enum DtyTagType
        {
            [Description("float")]
            Float = 1,
            [Description("bool")]
            Bool,
            [Description("string")]
            String,
            [Description("int")]
            Int
        }

        public enum DtyDigs
        {
            Zero,
            One,
            Two,
            Three,
            Four
        }

        public static DateTime GetLocalDT(object DT)
        {
            return Convert.ToDateTime(DT).ToLocalTime();
        }

        //WinCC归档使用的是UTC时间，因此需要转换一下
        /// <summary>
        /// 本地时间转换成UTC时间
        /// </summary>
        /// <param name="strtime">本地时间</param>
        /// <returns></returns>
        public static string GetWinCCDateTime(string strtime)
        {
            return System.DateTime.Parse(strtime).ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
        }
        public static string GetWinCCDateTime(DateTime LocalDT)
        {
            return System.DateTime.Parse(LocalDT.ToString()).ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
        }
       
    }
}
